import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
 * hidden: true                   如果`隐藏：真`不会显示在侧边栏中（默认值为false）
 * alwaysShow: true               如果设置为true，则无论子菜单的长度如何，都将始终显示根菜单
 *                                如果不设置alwaysShow，则只有多条路线下的子项
 *                                它将变成嵌套模式，否则不显示根菜单
 * redirect: noredirect           if `redirect:noredirect` will 面包屑中没有重定向
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
 **/
export const constantRouterMap = [
    {path: '/login', component: () => import('@/views/login/index'), hidden: true},
    {path: '/404', component: () => import('@/views/404'), hidden: true},

    {
        path: '/',
        component: Layout,
        redirect: '/dashboard',
        name: 'Dashboard',
        hidden: true,
        children: [{
            path: 'dashboard',
            component: () => import('@/views/dashboard/index')
        }]
    },
    //用户管理管理
    {
        path: '/presentLp',
        component: Layout,
        redirect: '/encash/list',
        name: '礼品管理',
        meta: {title: '礼品管理', icon: 'example'},
        children: [
            {
                path: 'presentLp',
                name: '礼品库存管理',
                component: () => import('@/views/presentLp/presentlist'),
                meta: {title: '礼品库存管理', icon: 'table'}
            },
            {
                path: 'presentadd',
                name: '礼品添加',
                component: () => import('@/views/presentLp/presentadd'),
                meta: {title: '礼品添加', icon: 'tree'}
            }
        ]
    },
    //用户管理管理
    {
        path: '/scratch',
        component: Layout,
        redirect: '/encash/list',
        name: '库存管理',
        meta: {title: '刮刮卡库存管理', icon: 'example'},
        children: [
            {
                path: 'scratch_vardInfo',
                name: '刮刮卡信息',
                component: () => import('@/views/scratch/scratch_vardInfo'),
                meta: {title: '刮刮卡信息', icon: 'table'}
            },
            {
                path: 'scratch_cardInfoadd',
                name: '刮刮卡库存添加',
                component: () => import('@/views/scratch/scratch_cardInfoadd'),
                meta: {title: '刮刮卡库存添加', icon: 'table'}
            }
        ]
    },
    //礼品库存管理
    {
        path: '/gift',
        component: Layout,
        redirect: '/encash/list',
        name: '礼品库存管理',
        meta: {title: '礼品库存管理', icon: 'example'},
        children: [
            {
                path: 'gift_query',
                name: '礼品信息',
                component: () => import('@/views/gift/gift_query'),
                meta: {title: '礼品库存管理', icon: 'table'}
            },
            {
                path: 'gift_add',
                name: '礼品库存添加',
                component: () => import('@/views/gift/gift_add.vue'),
                meta: {title: '礼品库存添加', icon: 'table'}
            }
        ]
    },
    //积分商城
    {
        path: '/integral',
        component: Layout,
        redirect: '/encash/list',
        name: '积分商城',
        meta: {title: '积分商城', icon: 'example'},
        children: [
            {
                path: 'list',
                name: '商品兑换记录查看',
                component: () => import('@/views/integral/list'),
                meta: {title: '商品兑换记录', icon: 'table'}
            },
            {
                path: 'integralList',
                name: '查看商品',
                component: () => import('@/views/integral/integralList'),
                meta: {title: '商品查看', icon: 'table'}
            },
            {
                path: 'CommodityAdd',
                name: '添加商品',
                component: () => import('@/views/integral/CommodityAdd'),
                meta: {title: '添加商品', icon: 'table'}
            }
        ]
    },
    //刮刮卡日志管理
    {
        path: '/prize',
        component: Layout,
        redirect: '/encash/list',
        name: '刮刮卡日志管理',
        meta: {title: '刮刮卡日志管理', icon: 'example'},
        children: [
            {
                path: 'list',
                name: '日志信息',
                component: () => import('@/views/ggkgm/list'),
                meta: {title: '日志信息', icon: 'table'}
            },
            {
                path: 'add',
                name: '日志添加',
                component: () => import('@/views/ggkgm/add'),
                meta: {title: '日志添加', icon: 'tree'}
            }
        ]
    },
    //统计报表
    {
        path: '/statistical',
        component: Layout,
        redirect: '/encash/list',
        name: '统计报表',
        meta: {title: '统计报表', icon: 'example'},
        children: [
            {
                path: 'scratch_obtain',
                name: '刮奖卡领取报表',
                component: () => import('@/views/statistical/scratch_obtain'),
                meta: {title: '刮奖卡领取报表', icon: 'table'}
            },
            {
                path: 'scratch_encash',
                name: '兑奖情况报表',
                component: () => import('@/views/statistical/scratch_encash'),
                meta: {title: '兑奖情况报表', icon: 'table'}
            },

            {
                path: 'scratch_giftlog',
                name: '礼品领取报表',
                component: () => import('@/views/statistical/scratch_giftlog'),
                meta: {title: '礼品领取报表', icon: 'table'}
            }
        ]
    },
    //礼品配置
    {
        path: '/ggkConfig',
        component: Layout,
        redirect: '/ggkConfig/list',
        name: '礼品配置',
        meta: {title: '礼品配置', icon: 'example'},
        children: [
            {
                path: 'list',
                name: '根据营业厅配置营业厅',
                component: () => import('@/views/ggkConfig/list'),
                meta: {title: '营业厅列表', icon: 'table'}
            },
            // {
            //     path: 'exchange',
            //     name: '礼品兑换',
            //     component: () => import('@/views/ggkConfig/exchange'),
            //     meta: {title: '礼品兑换', icon: 'tree'}
            // },
            {
                path: 'edit/:id',
                name: '礼品配置',
                component: () => import('@/views/ggkConfig/conf'),
                meta: {title: '礼品配置', noCache: true},
                hidden: true
            }
        ]
    },
    {
        path: '/saleplanpara',
        component: Layout,
        redirect: '/saleplanpara/sale',
        name: '营销活动',
        meta: {title: '营销活动', icon: 'example'},
        children: [
            {
                path: 'table',
                name: '营销活动设置',
                component: () => import('@/views/saleplanpara/sale'),
                meta: {title: '营销活动设置', icon: 'table'}
            },

        ]
    },

    {
        path: '/form',
        component: Layout,
        children: [
            {
                path: 'index',
                name: 'Form',
                component: () => import('@/views/form/index'),
                meta: {title: 'Form', icon: 'form'}
            }
        ]
    },

    {
        path: '/nested',
        component: Layout,
        redirect: '/nested/menu1',
        name: 'Nested',
        meta: {
            title: 'Nested',
            icon: 'nested'
        },
        children: [
            {
                path: 'menu1',
                component: () => import('@/views/nested/menu1/index'), // Parent router-view
                name: 'Menu1',
                meta: {title: 'Menu1'},
                children: [
                    {
                        path: 'menu1-1',
                        component: () => import('@/views/nested/menu1/menu1-1'),
                        name: 'Menu1-1',
                        meta: {title: 'Menu1-1'}
                    },
                    {
                        path: 'menu1-2',
                        component: () => import('@/views/nested/menu1/menu1-2'),
                        name: 'Menu1-2',
                        meta: {title: 'Menu1-2'},
                        children: [
                            {
                                path: 'menu1-2-1',
                                component: () => import('@/views/nested/menu1/menu1-2/menu1-2-1'),
                                name: 'Menu1-2-1',
                                meta: {title: 'Menu1-2-1'}
                            },
                            {
                                path: 'menu1-2-2',
                                component: () => import('@/views/nested/menu1/menu1-2/menu1-2-2'),
                                name: 'Menu1-2-2',
                                meta: {title: 'Menu1-2-2'}
                            }
                        ]
                    },
                    {
                        path: 'menu1-3',
                        component: () => import('@/views/nested/menu1/menu1-3'),
                        name: 'Menu1-3',
                        meta: {title: 'Menu1-3'}
                    }
                ]
            },
            {
                path: 'menu2',
                component: () => import('@/views/nested/menu2/index'),
                meta: {title: 'menu2'}
            }
        ]
    },

    {
        path: 'external-link',
        component: Layout,
        children: [
            {
                path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
                meta: {title: 'External Link', icon: 'link'}
            }
        ]
    },

    {path: '*', redirect: '/404', hidden: true}
]

export default new Router({
    // mode: 'history', //后端支持可开
    scrollBehavior: () => ({y: 0}),
    routes: constantRouterMap
})
